package com.heima.common.exception;


import com.heima.model.common.enums.AppHttpCodeEnum;

/**
 * 自定义异常
 */
public class CustomException extends RuntimeException {

    private AppHttpCodeEnum appHttpCodeEnum;

    public CustomException(AppHttpCodeEnum appHttpCodeEnum) {
        this.appHttpCodeEnum = appHttpCodeEnum;
    }

    public CustomException(AppHttpCodeEnum appHttpCodeEnum, String message) {
        super(message);
        this.appHttpCodeEnum = appHttpCodeEnum;
    }

    public CustomException() {
    }

    public AppHttpCodeEnum getAppHttpCodeEnum() {
        return appHttpCodeEnum;
    }

    /**
     * 为简化代码，配置以下静态方法
     */
    public static void cust(AppHttpCodeEnum appHttpCodeEnum) {
        throw new CustomException(appHttpCodeEnum);
    }

    public static void cust(AppHttpCodeEnum appHttpCodeEnum, String message) {
        throw new CustomException(appHttpCodeEnum, message);
    }

}
